﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using FlyHorse.LIMS.Model;
using FlyHorse.LIMS.WinApp.LanguageResource;

namespace FlyHorse.LIMS.WinApp.OtherForms
{
    public partial class SetOrderForm : DevExpress.XtraEditors.XtraForm
    {
        BLL.TestItemBll testItemBll = new BLL.TestItemBll();
        BLL.StandardSemiBll standardSemiBll = new BLL.StandardSemiBll();
        Action<TestItem, int> _ChangeOrder;
        public SetOrderForm(Action<TestItem,int> ChangeOrder)
        {
            InitializeComponent();
            _ChangeOrder = ChangeOrder;
        }

        private void SetOrderForm_Load(object sender, EventArgs e)
        {
             var testItemList=  testItemBll.LoadEntities(m => true).ToList();
             this.searchLookUpEdit1.Properties.DataSource = testItemList;
             
        }

        private void simpleButton_save_Click(object sender, EventArgs e)
        {
            if (this.searchLookUpEdit1.EditValue == null || this.searchLookUpEdit1.Text == "请选择" || this.searchLookUpEdit1.Text == "")
            {
                XtraMessageBox.Show(ResourceOverall.InputNull);
                return;
            }
            try
            {
                string testItemID = Convert.ToString(this.searchLookUpEdit1.EditValue);
                int order = Convert.ToInt32(this.textEdit1.Text);
                TestItem testItem = testItemBll.LoadEntities(m => m.TestItemID == testItemID).FirstOrDefault();
                if (testItem != null)
                {
                    _ChangeOrder(testItem, order);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
            }
            

        }
    }
}